package com.xiaoxu.privatechat.dao.common;


import com.xiaoxu.privatechat.entity.common.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description 好友数据库操作层
 * @date 2023/2/13
 * @author xiaoxu
 */
@Repository
public interface FriendDao extends JpaRepository<Friend, Long> {

	/**
	 * @description 根据好友id查询好友信息
	 * @param id 好友id
	 * @return Friend
	 */
	@Query("select f from Friend f where f.id = :id")
	Friend find(@Param("id")Long id);

	/**
	 * @description 根据账户id查找好友
	 * @param accountId 账户id
	 * @return List<Friend>
	 */
	List<Friend> findByAccountId(Long accountId);
}
